<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 6.0.0">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">

<link rel="stylesheet" href="//fonts.googleapis.com/css?family=Monda:300,300italic,400,400italic,700,700italic|Roboto Slab:300,300italic,400,400italic,700,700italic|PT Mono:300,300italic,400,400italic,700,700italic&display=swap&subset=latin,latin-ext">
<link rel="stylesheet" href="/lib/font-awesome/css/font-awesome.min.css">
  <link rel="stylesheet" href="/lib/pace/pace-theme-center-circle.min.css">
  <script src="/lib/pace/pace.min.js"></script>


<script id="hexo-configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    hostname: new URL('http://example.com').hostname,
    root: '/',
    scheme: 'Gemini',
    version: '7.7.0',
    exturl: false,
    sidebar: {"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},
    copycode: {"enable":false,"show_result":false,"style":null},
    back2top: {"enable":true,"sidebar":false,"scrollpercent":false},
    bookmark: {"enable":false,"color":"#222","save":"auto"},
    fancybox: false,
    mediumzoom: false,
    lazyload: false,
    pangu: false,
    comments: {"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},
    algolia: {
      appID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    },
    localsearch: {"enable":false,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},
    path: 'search.xml',
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}}
  };
</script>

  <meta name="description" content="针对力扣第8题的思路和程序，重点学习JAVA实现自动机的写法。">
<meta property="og:type" content="article">
<meta property="og:title" content="力扣刷题笔记，8. 字符串整数转换">
<meta property="og:url" content="http://example.com/2022/02/22/%E5%8A%9B%E6%89%A3%E5%88%B7%E9%A2%98%E7%AC%94%E8%AE%B0%EF%BC%9A8-%E5%8A%9B%E6%89%A3%E5%88%B7%E9%A2%98%E7%AC%94%E8%AE%B0%EF%BC%9A8/index.html">
<meta property="og:site_name" content="LWWm">
<meta property="og:description" content="针对力扣第8题的思路和程序，重点学习JAVA实现自动机的写法。">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2022-02-22T13:03:21.000Z">
<meta property="article:modified_time" content="2022-02-23T06:12:49.845Z">
<meta property="article:author" content="LWWm">
<meta property="article:tag" content="力扣刷题笔记">
<meta name="twitter:card" content="summary">

<link rel="canonical" href="http://example.com/2022/02/22/%E5%8A%9B%E6%89%A3%E5%88%B7%E9%A2%98%E7%AC%94%E8%AE%B0%EF%BC%9A8-%E5%8A%9B%E6%89%A3%E5%88%B7%E9%A2%98%E7%AC%94%E8%AE%B0%EF%BC%9A8/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome: false,
    isPost: true
  };
</script>

  <title>力扣刷题笔记，8. 字符串整数转换 | LWWm</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

<link rel="alternate" href="/atom.xml" title="LWWm" type="application/atom+xml">
</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-meta">

    <div>
      <a href="/" class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">LWWm</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
  </div>

  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>
</div>


<nav class="site-nav">
  
  <ul id="menu" class="menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-fw fa-home"></i>首页</a>

  </li>
        <li class="menu-item menu-item-tags">

    <a href="/tags/" rel="section"><i class="fa fa-fw fa-tags"></i>标签</a>

  </li>
        <li class="menu-item menu-item-categories">

    <a href="/categories/" rel="section"><i class="fa fa-fw fa-th"></i>分类</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-fw fa-archive"></i>归档</a>

  </li>
  </ul>

</nav>
</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content">
            

  <div class="posts-expand">
      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block " lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2022/02/22/%E5%8A%9B%E6%89%A3%E5%88%B7%E9%A2%98%E7%AC%94%E8%AE%B0%EF%BC%9A8-%E5%8A%9B%E6%89%A3%E5%88%B7%E9%A2%98%E7%AC%94%E8%AE%B0%EF%BC%9A8/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.jpg">
      <meta itemprop="name" content="LWWm">
      <meta itemprop="description" content="若能美梦成真，何羡妖魔鬼神">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="LWWm">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          力扣刷题笔记，8. 字符串整数转换
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2022-02-22 21:03:21" itemprop="dateCreated datePublished" datetime="2022-02-22T21:03:21+08:00">2022-02-22</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="fa fa-calendar-check-o"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2022-02-23 14:12:49" itemprop="dateModified" datetime="2022-02-23T14:12:49+08:00">2022-02-23</time>
              </span>

          
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2022/02/22/%E5%8A%9B%E6%89%A3%E5%88%B7%E9%A2%98%E7%AC%94%E8%AE%B0%EF%BC%9A8-%E5%8A%9B%E6%89%A3%E5%88%B7%E9%A2%98%E7%AC%94%E8%AE%B0%EF%BC%9A8/#comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2022/02/22/%E5%8A%9B%E6%89%A3%E5%88%B7%E9%A2%98%E7%AC%94%E8%AE%B0%EF%BC%9A8-%E5%8A%9B%E6%89%A3%E5%88%B7%E9%A2%98%E7%AC%94%E8%AE%B0%EF%BC%9A8/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <h3 id="针对力扣第8题的思路和程序，重点学习JAVA实现自动机的写法。"><a href="#针对力扣第8题的思路和程序，重点学习JAVA实现自动机的写法。" class="headerlink" title="针对力扣第8题的思路和程序，重点学习JAVA实现自动机的写法。"></a>针对力扣第8题的思路和程序，重点学习JAVA实现自动机的写法。</h3><span id="more"></span>

<h2 id="1-自动机"><a href="#1-自动机" class="headerlink" title="1.自动机"></a>1.自动机</h2><p>&amp;ensp;&amp;ensp;字符串中的数字为结果的条件是：这个数字（包含符号）的前面只有空格<br>&amp;emsp;每次输入的字符包括四种情况：空格“ ”，符号“+&#x2F;-”，数字，其他。<br>同时对应有四种状态：<br>&amp;emsp;&amp;emsp; -开始状态(start)，即尚未读取到符号或者数字，只读取到空格或未读取<br>&amp;emsp;&amp;emsp; -符号状态(signed)，即在开始状态下读取到一个符号<br>&amp;emsp;&amp;emsp; -拼数字状态(in_number)，即在开始状态或者符号状态或者数字状态下又读取到一个数字<br>&amp;emsp;&amp;emsp; -结束状态(end)，即已经读完数字或者在开始状态下即读取到非数字且非符号，或者符号状态读取到非数字。</p>
<p>&amp;emsp;状态转移表如下：</p>
<table>
<thead>
<tr>
<th></th>
<th>“ “</th>
<th>+&#x2F;-</th>
<th>number</th>
<th>other</th>
</tr>
</thead>
<tbody><tr>
<td>start</td>
<td>start</td>
<td>sighed</td>
<td>in_number</td>
<td>end</td>
</tr>
<tr>
<td>signed</td>
<td>end</td>
<td>end</td>
<td>in_number</td>
<td>end</td>
</tr>
<tr>
<td>in_number</td>
<td>end</td>
<td>end</td>
<td>in_number</td>
<td>end</td>
</tr>
<tr>
<td>end</td>
<td>end</td>
<td>end</td>
<td>end</td>
<td>end</td>
</tr>
</tbody></table>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br></pre></td><td class="code"><pre><span class="line">class Solution &#123;</span><br><span class="line">    public int myAtoi(String s) &#123;</span><br><span class="line">        Automation automation = new Automation();</span><br><span class="line">        for (char c : s.toCharArray()) &#123;</span><br><span class="line">            automation.get(c);</span><br><span class="line">        &#125;</span><br><span class="line">        return (int) (automation.sign * automation.ans);</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">class Automation &#123;</span><br><span class="line">    enum States&#123;</span><br><span class="line">        START, SIGNED, IN_NUMBER, END;</span><br><span class="line">    &#125;</span><br><span class="line">    public int sign = 1;    // 结果的符号，如果读到有效的“-”,则变为-1</span><br><span class="line">    public long ans = 0;    // 用于存放得到的结果,始终是正数,long类型为了防止结果溢出</span><br><span class="line">    private States state = States.START;    // 表示状态，默认为开始状态</span><br><span class="line">    private Map&lt;States,States[]&gt; table = new HashMap&lt;&gt;();</span><br><span class="line"></span><br><span class="line">    public Automation() &#123;</span><br><span class="line">        // table 赋值,数组中对应输入分别为 空格“ ”，符号“+/-”，数字，其他 时的次状态</span><br><span class="line">        table.put(States.START, new States[] &#123;States.START, States.SIGNED, States.IN_NUMBER, States.END&#125;);</span><br><span class="line">        table.put(States.SIGNED, new States[] &#123;States.END, States.END, States.IN_NUMBER, States.END&#125;);</span><br><span class="line">        table.put(States.IN_NUMBER, new States[] &#123;States.END, States.END, States.IN_NUMBER, States.END&#125;);</span><br><span class="line">        table.put(States.END, new States[] &#123;States.END, States.END, States.END, States.END&#125;);</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    public void get(char c) &#123;</span><br><span class="line">        // 根据当前状态和输入得到次状态</span><br><span class="line">        state = table.get(state)[getValue(c)];</span><br><span class="line">        // 只有次状态为数字或者符号的时候才会影响结果</span><br><span class="line">        if (state == States.IN_NUMBER) &#123;</span><br><span class="line">            ans = ans * 10 + c - &#x27;0&#x27;;</span><br><span class="line">            // 分正负结果分别处理结果溢出 </span><br><span class="line">            if (sign == 1) &#123;</span><br><span class="line">                ans = Math.min(ans, (long)Integer.MAX_VALUE);</span><br><span class="line">            &#125; else &#123;</span><br><span class="line">                ans = Math.min(ans, -(long)Integer.MIN_VALUE);</span><br><span class="line">            &#125;</span><br><span class="line">        &#125; else if (state == States.SIGNED) &#123;</span><br><span class="line">            sign = c == &#x27;+&#x27; ? 1 : -1;</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    public int getValue(char c) &#123;</span><br><span class="line">        if (c == &#x27; &#x27;)</span><br><span class="line">            return 0;</span><br><span class="line">        if (c == &#x27;+&#x27; || c == &#x27;-&#x27;)</span><br><span class="line">            return 1;</span><br><span class="line">        if (Character.isDigit(c))</span><br><span class="line">            return 2;</span><br><span class="line">        return 3;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h2 id="2-直接模拟"><a href="#2-直接模拟" class="headerlink" title="2. 直接模拟"></a>2. 直接模拟</h2><p>&amp;emsp;先使用API去掉前导和尾部空白，对剩下的进行判断：</p>
<ol>
<li>如果开始是数字，则合法，修改结果，指针进一继续判断；</li>
<li>如果开始是符号，则合法，修改结果符号，指针进一继续判断；</li>
</ol>
<ul>
<li>如果是数字，则合法，修改结果，指针进一继续判断;</li>
<li>如果是其他，则非法，结束；</li>
</ul>
<ol start="3">
<li>如果是其他，则非法，结束。</li>
</ol>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br></pre></td><td class="code"><pre><span class="line">class Solution &#123;</span><br><span class="line">    public int myAtoi(String s) &#123;</span><br><span class="line">        String s1 = s.trim();   // 去掉s的前导和尾部空白</span><br><span class="line">        if (s1.length() &lt; 1)</span><br><span class="line">            return 0;</span><br><span class="line">        long ans = 0;           // long 类型防止溢出，恒为正值</span><br><span class="line">        int index = 0;          // 当前下标</span><br><span class="line">        int sign = 1;           // 符号</span><br><span class="line"></span><br><span class="line">        // s1 的首个字符三种可能</span><br><span class="line">        // 如果是+/-则修改符号，并下标右移</span><br><span class="line">        if (s1.charAt(index) == &#x27;+&#x27;) &#123;</span><br><span class="line">            sign = 1;</span><br><span class="line">            index ++;</span><br><span class="line">        &#125; else if (s1.charAt(index) == &#x27;-&#x27;) &#123;</span><br><span class="line">            sign = -1;</span><br><span class="line">            index ++;</span><br><span class="line">        &#125;</span><br><span class="line">        // 如果是数字或者其他</span><br><span class="line">        for (int i = index; i &lt; s1.length(); i++) &#123;</span><br><span class="line">            char c = s1.charAt(i);</span><br><span class="line">            // 如果是数字</span><br><span class="line">            if (Character.isDigit(c)) &#123;</span><br><span class="line">                ans = ans * 10 + c - &#x27;0&#x27;;</span><br><span class="line">                // 分类处理溢出</span><br><span class="line">                if (sign == 1) &#123;</span><br><span class="line">                    ans = Math.min(ans, Integer.MAX_VALUE);</span><br><span class="line">                &#125; else &#123;</span><br><span class="line">                    ans = Math.min(ans,-(long)Integer.MIN_VALUE);</span><br><span class="line">                &#125;</span><br><span class="line">            &#125; else &#123;</span><br><span class="line">                // 如果是其他则结束返回结果</span><br><span class="line">                break;</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">        return (int) (sign * ans);</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
    </div>

    
    
    
        

<div>
<ul class="post-copyright">
  <li class="post-copyright-author">
    <strong>本文作者： </strong>LWWm
  </li>
  <li class="post-copyright-link">
    <strong>本文链接：</strong>
    <a href="http://example.com/2022/02/22/%E5%8A%9B%E6%89%A3%E5%88%B7%E9%A2%98%E7%AC%94%E8%AE%B0%EF%BC%9A8-%E5%8A%9B%E6%89%A3%E5%88%B7%E9%A2%98%E7%AC%94%E8%AE%B0%EF%BC%9A8/" title="力扣刷题笔记，8. 字符串整数转换">http://example.com/2022/02/22/力扣刷题笔记：8-力扣刷题笔记：8/</a>
  </li>
  <li class="post-copyright-license">
    <strong>版权声明： </strong>本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" rel="noopener" target="_blank"><i class="fa fa-fw fa-creative-commons"></i>BY-NC-SA</a> 许可协议。转载请注明出处！
  </li>
</ul>
</div>


      <footer class="post-footer">
          <div class="post-tags">
              <a href="/tags/%E5%8A%9B%E6%89%A3%E5%88%B7%E9%A2%98%E7%AC%94%E8%AE%B0/" rel="tag"># 力扣刷题笔记</a>
          </div>

        


        
    <div class="post-nav">
      <div class="post-nav-item">
    <a href="/2022/02/22/my-first-blog/" rel="prev" title="my first blog">
      <i class="fa fa-chevron-left"></i> my first blog
    </a></div>
      <div class="post-nav-item"></div>
    </div>
      </footer>
    
  </article>
  
  
  

  </div>


          </div>
          
    <div class="comments" id="valine-comments"></div>

<script>
  window.addEventListener('tabs:register', () => {
    let activeClass = CONFIG.comments.activeClass;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
          <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-3"><a class="nav-link" href="#%E9%92%88%E5%AF%B9%E5%8A%9B%E6%89%A3%E7%AC%AC8%E9%A2%98%E7%9A%84%E6%80%9D%E8%B7%AF%E5%92%8C%E7%A8%8B%E5%BA%8F%EF%BC%8C%E9%87%8D%E7%82%B9%E5%AD%A6%E4%B9%A0JAVA%E5%AE%9E%E7%8E%B0%E8%87%AA%E5%8A%A8%E6%9C%BA%E7%9A%84%E5%86%99%E6%B3%95%E3%80%82"><span class="nav-number">1.</span> <span class="nav-text">针对力扣第8题的思路和程序，重点学习JAVA实现自动机的写法。</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#1-%E8%87%AA%E5%8A%A8%E6%9C%BA"><span class="nav-number"></span> <span class="nav-text">1.自动机</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#2-%E7%9B%B4%E6%8E%A5%E6%A8%A1%E6%8B%9F"><span class="nav-number"></span> <span class="nav-text">2. 直接模拟</span></a></div>
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="LWWm"
      src="/images/avatar.jpg">
  <p class="site-author-name" itemprop="name">LWWm</p>
  <div class="site-description" itemprop="description">若能美梦成真，何羡妖魔鬼神</div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">3</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/tags/">
          
        <span class="site-state-item-count">1</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>
  <div class="links-of-author motion-element">
      <span class="links-of-author-item">
        <a href="https://github.com/LWWm" title="GitHub → https:&#x2F;&#x2F;github.com&#x2F;LWWm" rel="noopener" target="_blank"><i class="fa fa-fw fa-github"></i>GitHub</a>
      </span>
  </div>
  <div class="cc-license motion-element" itemprop="license">
    <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" class="cc-opacity" rel="noopener" target="_blank"><img src="/images/cc-by-nc-sa.svg" alt="Creative Commons"></a>
  </div>



      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2022</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">LWWm</span>
</div>
  <div class="powered-by">由 <a href="https://hexo.io/" class="theme-link" rel="noopener" target="_blank">Hexo</a> 强力驱动 v6.0.0
  </div>
  <span class="post-meta-divider">|</span>
  <div class="theme-info">主题 – <a href="https://theme-next.org/" class="theme-link" rel="noopener" target="_blank">NexT.Gemini</a> v7.7.0
  </div>

        








      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>

<script src="/js/utils.js"></script>

<script src="/js/motion.js"></script>


<script src="/js/schemes/pisces.js"></script>


<script src="/js/next-boot.js"></script>


  <script defer src="/lib/three/three.min.js"></script>


  















  

  


<script>
NexT.utils.loadComments(document.querySelector('#valine-comments'), () => {
  NexT.utils.getScript('//unpkg.com/valine/dist/Valine.min.js', () => {
    var GUEST = ['nick', 'mail', 'link'];
    var guest = 'nick,mail,link';
    guest = guest.split(',').filter(item => {
      return GUEST.includes(item);
    });
    new Valine({
      el: '#valine-comments',
      verify: false,
      notify: false,
      appId: 'OGFL4wP8lX2ntYFw8I8fX3WC-gzGzoHsz',
      appKey: 'iTCoHh5qKPvUDuz0bBUzVBIS',
      placeholder: "Just go go",
      avatar: 'robohash',
      meta: guest,
      pageSize: '10' || 10,
      visitor: false,
      lang: '' || 'zh-cn',
      path: location.pathname,
      recordIP: false,
      serverURLs: ''
    });
  }, window.Valine);
});
</script>

<script src="/live2dw/lib/L2Dwidget.min.js?094cbace49a39548bed64abff5988b05"></script><script>L2Dwidget.init({"log":false,"pluginJsPath":"lib/","pluginModelPath":"assets/","pluginRootPath":"live2dw/","tagMode":false});</script></body>
</html>
